package nuist.hanniko.stu.webbackend.dao.mapper;

import nuist.hanniko.stu.webbackend.model.LwM2m.LwM2mObject;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface LwM2mObjectMapper {

    @Insert({
            "<script>",
            "insert ignore into device_objects(device_id, object_id, name) ",
            "values ",
            "<foreach collection='objects' item='item' separator=','>",
            "( #{item.deviceId}, #{item.objectId}, #{item.name})",
            "</foreach>",
            "</script>"
    })
    void insertBatch(@Param("objects") List<LwM2mObject> objects);

}
